home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Database
/
RandomTableView
/
TableViewController.m
< prev
next >
Wrap
Text File
|
1994-02-15
|
2KB
|
75 lines
/* TableViewController.m:
* You may freely copy, distribute, and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*
*
*
*/
#import <dbkit/dbkit.h>
#import "TableViewController.h"
#import "RandomDataSource.h"
#define ROWCOUNT 20
#define COLUMNCOUNT 4
@implementation TableViewController
- appDidInit:sender
{
NXRect viewFrame;
int i;
[[tableView getFrame:&viewFrame] free];
tableView = [[DBTableView alloc] initFrame:&viewFrame];
[[window contentView] addSubview:tableView];
theDataSource = [[RandomDataSource alloc] init];
[theDataSource setRows:ROWCOUNT];
[theDataSource setColumns:COLUMNCOUNT];
[theDataSource loadData];
for (i= 0; i < COLUMNCOUNT; i++) {
char buf[100];
sprintf(buf, "Column %d", i);
[tableView addColumn:(id) i withTitle:buf];
}
[tableView setDataSource:theDataSource];
[tableView setDelegate:self];
[self setUpTableView];
return self;
}
- setUpTableView
{
int i;
id <DBTableVectors> columnVector = nil;
/*
* Set up tableview with some default configuration.
*/
[window disableFlushWindow];
[tableView setMode:DB_LISTMODE];
[tableView acceptArrowKeys:YES];
[tableView allowVectorResizing:YES];
/* initialize the tableview with a fixed column width */
for (i= 0; i < COLUMNCOUNT; i++) {
columnVector = [tableView columnAt:i];
[columnVector setMinSize:50.0];
}
[tableView setEditable:YES];
[tableView setColumnHeadingVisible:YES];
[[window reenableFlushWindow] flushWindow];
[tableView display];
return self;
}
@end